<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%
//URL ejemplo: http://localhost:82/AppCooperativaDWP/FacArticulos.jsp?art_barras=7792900006857
String param = "";
if (request.getParameter("art_barras") != null && request.getParameter("art_barras") != ""){
	param = request.getParameter("art_barras"); //nombre del parametro.
}else{
	param = "$$$";
}

//   int iparam = Integer.parseInt(param);
try{
	System.out.print("parametro: "+param);
	Class.forName("com.sybase.jdbc3.jdbc.SybDriver").newInstance();
	String url, user, pass;
	//puertos 5000, 2638
	url = "jdbc:sybase:Tds:132.147.160.40:5000/super9_bak";
	user = "dba";
	pass = "sql";
	
	Connection cn = DriverManager.getConnection(url, user, pass);
/* CONSULTA:
	select art.* from fac_articulos_barras as b, fac_articulos as art where b.art_codigo = art.art_codigo and b.art_barras = '7796045109022';*/																												//parametro	
// 	PreparedStatement cmd = cn.prepareStatement("select art.* from fac_articulos_barras as b, fac_articulos as art where b.art_codigo = art.art_codigo and b.art_barras = ?;");
	PreparedStatement cmd = cn.prepareStatement("select * from fac_articulos where art_barras = ?;");
	cmd.setString(1, param);
	ResultSet rs = cmd.executeQuery();
	
	while (rs.next()){ //el nombre pasado, deben ser las columnas de la tablas en la base.
		out.print(rs.getString("art_barras")+", "+ 
 					rs.getString("art_descri")+", "+
					rs.getString("art_existencia")); 
	}
	
	rs.close();
	cmd.close();
	cn.close();
}catch (Exception e){
	out.print(e.getMessage());
}
%>